<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-2"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-3"></span><span class="hs-comment">-- Module      :  Control.Concurrent.STM.TSem</span><span>
</span><span id="line-4"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow 2012</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/base/LICENSE)</span><span>
</span><span id="line-6"></span><span class="hs-comment">--</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Stability   :  experimental</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Portability :  non-portable (requires STM)</span><span>
</span><span id="line-10"></span><span class="hs-comment">--</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- 'TSem': transactional semaphores.</span><span>
</span><span id="line-12"></span><span class="hs-comment">--</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- @since 2.4.2</span><span>
</span><span id="line-14"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-15"></span><span>
</span><span id="line-16"></span><span class="hs-pragma">{-# LANGUAGE DeriveDataTypeable #-}</span><span>
</span><span id="line-17"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Control.Concurrent.STM.TSem</span><span>
</span><span id="line-18"></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#TSem"><span class="hs-identifier">TSem</span></a></span><span>
</span><span id="line-19"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#newTSem"><span class="hs-identifier">newTSem</span></a></span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#waitTSem"><span class="hs-identifier">waitTSem</span></a></span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#signalTSem"><span class="hs-identifier">signalTSem</span></a></span><span>
</span><span id="line-24"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#signalTSemN"><span class="hs-identifier">signalTSemN</span></a></span><span>
</span><span id="line-25"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.html"><span class="hs-identifier">Control.Concurrent.STM</span></a></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Typeable.html#"><span class="hs-identifier">Data.Typeable</span></a></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Numeric.Natural.html#"><span class="hs-identifier">Numeric.Natural</span></a></span><span>
</span><span id="line-31"></span><span>
</span><span id="line-32"></span><span class="hs-comment">-- | 'TSem' is a transactional semaphore.  It holds a certain number</span><span>
</span><span id="line-33"></span><span class="hs-comment">-- of units, and units may be acquired or released by 'waitTSem' and</span><span>
</span><span id="line-34"></span><span class="hs-comment">-- 'signalTSem' respectively.  When the 'TSem' is empty, 'waitTSem'</span><span>
</span><span id="line-35"></span><span class="hs-comment">-- blocks.</span><span>
</span><span id="line-36"></span><span class="hs-comment">--</span><span>
</span><span id="line-37"></span><span class="hs-comment">-- Note that 'TSem' has no concept of fairness, and there is no</span><span>
</span><span id="line-38"></span><span class="hs-comment">-- guarantee that threads blocked in `waitTSem` will be unblocked in</span><span>
</span><span id="line-39"></span><span class="hs-comment">-- the same order; in fact they will all be unblocked at the same time</span><span>
</span><span id="line-40"></span><span class="hs-comment">-- and will fight over the 'TSem'.  Hence 'TSem' is not suitable if</span><span>
</span><span id="line-41"></span><span class="hs-comment">-- you expect there to be a high number of threads contending for the</span><span>
</span><span id="line-42"></span><span class="hs-comment">-- resource.  However, like other STM abstractions, 'TSem' is</span><span>
</span><span id="line-43"></span><span class="hs-comment">-- composable.</span><span>
</span><span id="line-44"></span><span class="hs-comment">--</span><span>
</span><span id="line-45"></span><span class="hs-comment">-- @since 2.4.2</span><span>
</span><span id="line-46"></span><span class="hs-keyword">newtype</span><span> </span><span id="TSem"><span class="annot"><a href="Control.Concurrent.STM.TSem.html#TSem"><span class="hs-identifier hs-var">TSem</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="TSem"><span class="annot"><a href="Control.Concurrent.STM.TSem.html#TSem"><span class="hs-identifier hs-var">TSem</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#TVar"><span class="hs-identifier hs-type">TVar</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Integer</span></span><span class="hs-special">)</span><span>
</span><span id="line-47"></span><span>  </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679037718"><span id="local-6989586621679037723"><span class="annot"><span class="annottext">TSem -&gt; TSem -&gt; Bool
(TSem -&gt; TSem -&gt; Bool) -&gt; (TSem -&gt; TSem -&gt; Bool) -&gt; Eq TSem
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: TSem -&gt; TSem -&gt; Bool
$c/= :: TSem -&gt; TSem -&gt; Bool
== :: TSem -&gt; TSem -&gt; Bool
$c== :: TSem -&gt; TSem -&gt; Bool
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></span></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Typeable.Internal.html#Typeable"><span class="hs-identifier hs-type">Typeable</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span class="hs-comment">-- | Construct new 'TSem' with an initial counter value.</span><span>
</span><span id="line-50"></span><span class="hs-comment">--</span><span>
</span><span id="line-51"></span><span class="hs-comment">-- A positive initial counter value denotes availability of</span><span>
</span><span id="line-52"></span><span class="hs-comment">-- units 'waitTSem' can acquire.</span><span>
</span><span id="line-53"></span><span class="hs-comment">--</span><span>
</span><span id="line-54"></span><span class="hs-comment">-- The initial counter value can be negative which denotes a resource</span><span>
</span><span id="line-55"></span><span class="hs-comment">-- \&quot;debt\&quot; that requires a respective amount of 'signalTSem'</span><span>
</span><span id="line-56"></span><span class="hs-comment">-- operations to counter-balance.</span><span>
</span><span id="line-57"></span><span class="hs-comment">--</span><span>
</span><span id="line-58"></span><span class="hs-comment">-- @since 2.4.2</span><span>
</span><span id="line-59"></span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#newTSem"><span class="hs-identifier hs-type">newTSem</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Integer</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#TSem"><span class="hs-identifier hs-type">TSem</span></a></span><span>
</span><span id="line-60"></span><span id="newTSem"><span class="annot"><span class="annottext">newTSem :: Integer -&gt; STM TSem
</span><a href="Control.Concurrent.STM.TSem.html#newTSem"><span class="hs-identifier hs-var hs-var">newTSem</span></a></span></span><span> </span><span id="local-6989586621679037713"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679037713"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TVar Integer -&gt; TSem) -&gt; STM (TVar Integer) -&gt; STM TSem
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">TVar Integer -&gt; TSem
</span><a href="Control.Concurrent.STM.TSem.html#TSem"><span class="hs-identifier hs-var">TSem</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer -&gt; STM (TVar Integer)
forall a. a -&gt; STM (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVar"><span class="hs-identifier hs-var">newTVar</span></a></span><span> </span><span class="annot"><span class="annottext">(Integer -&gt; STM (TVar Integer)) -&gt; Integer -&gt; STM (TVar Integer)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679037713"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-61"></span><span>
</span><span id="line-62"></span><span class="hs-comment">-- NOTE: we can't expose a good `TSem -&gt; STM Int' operation as blocked</span><span>
</span><span id="line-63"></span><span class="hs-comment">-- 'waitTSem' aren't reliably reflected in a negative counter value.</span><span>
</span><span id="line-64"></span><span>
</span><span id="line-65"></span><span class="hs-comment">-- | Wait on 'TSem' (aka __P__ operation).</span><span>
</span><span id="line-66"></span><span class="hs-comment">--</span><span>
</span><span id="line-67"></span><span class="hs-comment">-- This operation acquires a unit from the semaphore (i.e. decreases</span><span>
</span><span id="line-68"></span><span class="hs-comment">-- the internal counter) and blocks (via 'retry') if no units are</span><span>
</span><span id="line-69"></span><span class="hs-comment">-- available (i.e. if the counter is /not/ positive).</span><span>
</span><span id="line-70"></span><span class="hs-comment">--</span><span>
</span><span id="line-71"></span><span class="hs-comment">-- @since 2.4.2</span><span>
</span><span id="line-72"></span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#waitTSem"><span class="hs-identifier hs-type">waitTSem</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#TSem"><span class="hs-identifier hs-type">TSem</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-73"></span><span id="waitTSem"><span class="annot"><span class="annottext">waitTSem :: TSem -&gt; STM ()
</span><a href="Control.Concurrent.STM.TSem.html#waitTSem"><span class="hs-identifier hs-var hs-var">waitTSem</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#TSem"><span class="hs-identifier hs-type">TSem</span></a></span><span> </span><span id="local-6989586621679037710"><span class="annot"><span class="annottext">TVar Integer
</span><a href="#local-6989586621679037710"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-74"></span><span>  </span><span id="local-6989586621679037709"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679037709"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar Integer -&gt; STM Integer
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar Integer
</span><a href="#local-6989586621679037710"><span class="hs-identifier hs-var">t</span></a></span><span>
</span><span id="line-75"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; STM () -&gt; STM ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679037709"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">STM ()
forall a. STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#retry"><span class="hs-identifier hs-var">retry</span></a></span><span>
</span><span id="line-76"></span><span>  </span><span class="annot"><span class="annottext">TVar Integer -&gt; Integer -&gt; STM ()
forall a. TVar a -&gt; a -&gt; STM ()
</span><a href="../../base/src/GHC.Conc.Sync.html#writeTVar"><span class="hs-identifier hs-var">writeTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar Integer
</span><a href="#local-6989586621679037710"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">(Integer -&gt; STM ()) -&gt; Integer -&gt; STM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679037709"><span class="hs-identifier hs-var">i</span></a></span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-77"></span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span class="hs-comment">-- Alternatively, the implementation could block (via 'retry') when</span><span>
</span><span id="line-80"></span><span class="hs-comment">-- the next increment would overflow, i.e. testing for 'maxBound'</span><span>
</span><span id="line-81"></span><span>
</span><span id="line-82"></span><span class="hs-comment">-- | Signal a 'TSem' (aka __V__ operation).</span><span>
</span><span id="line-83"></span><span class="hs-comment">--</span><span>
</span><span id="line-84"></span><span class="hs-comment">-- This operation adds\/releases a unit back to the semaphore</span><span>
</span><span id="line-85"></span><span class="hs-comment">-- (i.e. increments the internal counter).</span><span>
</span><span id="line-86"></span><span class="hs-comment">--</span><span>
</span><span id="line-87"></span><span class="hs-comment">-- @since 2.4.2</span><span>
</span><span id="line-88"></span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#signalTSem"><span class="hs-identifier hs-type">signalTSem</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#TSem"><span class="hs-identifier hs-type">TSem</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-89"></span><span id="signalTSem"><span class="annot"><span class="annottext">signalTSem :: TSem -&gt; STM ()
</span><a href="Control.Concurrent.STM.TSem.html#signalTSem"><span class="hs-identifier hs-var hs-var">signalTSem</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#TSem"><span class="hs-identifier hs-type">TSem</span></a></span><span> </span><span id="local-6989586621679037703"><span class="annot"><span class="annottext">TVar Integer
</span><a href="#local-6989586621679037703"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-90"></span><span>  </span><span id="local-6989586621679037702"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679037702"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar Integer -&gt; STM Integer
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar Integer
</span><a href="#local-6989586621679037703"><span class="hs-identifier hs-var">t</span></a></span><span>
</span><span id="line-91"></span><span>  </span><span class="annot"><span class="annottext">TVar Integer -&gt; Integer -&gt; STM ()
forall a. TVar a -&gt; a -&gt; STM ()
</span><a href="../../base/src/GHC.Conc.Sync.html#writeTVar"><span class="hs-identifier hs-var">writeTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar Integer
</span><a href="#local-6989586621679037703"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">(Integer -&gt; STM ()) -&gt; Integer -&gt; STM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679037702"><span class="hs-identifier hs-var">i</span></a></span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">1</span></span><span>
</span><span id="line-92"></span><span>
</span><span id="line-93"></span><span>
</span><span id="line-94"></span><span class="hs-comment">-- | Multi-signal a 'TSem'</span><span>
</span><span id="line-95"></span><span class="hs-comment">--</span><span>
</span><span id="line-96"></span><span class="hs-comment">-- This operation adds\/releases multiple units back to the semaphore</span><span>
</span><span id="line-97"></span><span class="hs-comment">-- (i.e. increments the internal counter).</span><span>
</span><span id="line-98"></span><span class="hs-comment">--</span><span>
</span><span id="line-99"></span><span class="hs-comment">-- &gt; signalTSem == signalTSemN 1</span><span>
</span><span id="line-100"></span><span class="hs-comment">--</span><span>
</span><span id="line-101"></span><span class="hs-comment">-- @since 2.4.5</span><span>
</span><span id="line-102"></span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#signalTSemN"><span class="hs-identifier hs-type">signalTSemN</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Natural</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#TSem"><span class="hs-identifier hs-type">TSem</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-103"></span><span id="signalTSemN"><span class="annot"><span class="annottext">signalTSemN :: Natural -&gt; TSem -&gt; STM ()
</span><a href="Control.Concurrent.STM.TSem.html#signalTSemN"><span class="hs-identifier hs-var hs-var">signalTSemN</span></a></span></span><span> </span><span class="annot"><span class="annottext">Natural
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">TSem
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; STM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-104"></span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#signalTSemN"><span class="hs-identifier hs-var">signalTSemN</span></a></span><span> </span><span class="annot"><span class="annottext">Natural
</span><span class="hs-number">1</span></span><span> </span><span id="local-6989586621679037700"><span class="annot"><span class="annottext">TSem
</span><a href="#local-6989586621679037700"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TSem -&gt; STM ()
</span><a href="Control.Concurrent.STM.TSem.html#signalTSem"><span class="hs-identifier hs-var">signalTSem</span></a></span><span> </span><span class="annot"><span class="annottext">TSem
</span><a href="#local-6989586621679037700"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-105"></span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#signalTSemN"><span class="hs-identifier hs-var">signalTSemN</span></a></span><span> </span><span id="local-6989586621679037699"><span class="annot"><span class="annottext">Natural
</span><a href="#local-6989586621679037699"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TSem.html#TSem"><span class="hs-identifier hs-type">TSem</span></a></span><span> </span><span id="local-6989586621679037698"><span class="annot"><span class="annottext">TVar Integer
</span><a href="#local-6989586621679037698"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-106"></span><span>  </span><span id="local-6989586621679037697"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679037697"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar Integer -&gt; STM Integer
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar Integer
</span><a href="#local-6989586621679037698"><span class="hs-identifier hs-var">t</span></a></span><span>
</span><span id="line-107"></span><span>  </span><span class="annot"><span class="annottext">TVar Integer -&gt; Integer -&gt; STM ()
forall a. TVar a -&gt; a -&gt; STM ()
</span><a href="../../base/src/GHC.Conc.Sync.html#writeTVar"><span class="hs-identifier hs-var">writeTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar Integer
</span><a href="#local-6989586621679037698"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">(Integer -&gt; STM ()) -&gt; Integer -&gt; STM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679037697"><span class="hs-identifier hs-var">i</span></a></span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="hs-special">(</span><span class="annot"><span class="annottext">Natural -&gt; Integer
forall a. Integral a =&gt; a -&gt; Integer
</span><a href="../../base/src/GHC.Real.html#toInteger"><span class="hs-identifier hs-var">toInteger</span></a></span><span> </span><span class="annot"><span class="annottext">Natural
</span><a href="#local-6989586621679037699"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-108"></span></pre></body></html>